package com.designpattern.structure.facade;

/**
 * @author Administration
 * @date 2021/10/18 - 17:17 - 星期一
 * @project 结构型模式中得外观模式  外观（Facade）角色
 * @package com.designpattern.structure.facade
 * @by 晨
 */
public class SmartAppliancesFacade {

    private Light light;
    private TV tv;
    private AirCondition airCondition;

    public SmartAppliancesFacade() {
        light = new Light();
        tv = new TV();
        airCondition = new AirCondition();
    }

    public void say(String message) {
        if (message.contains("打开")) {
            this.on();
        } else if (message.contains("关闭")) {
            this.off();
        } else {
            System.out.println("我还听不懂你说的！！！");
        }
    }

    private void off() {
        light.off();
        tv.off();
        airCondition.off();
    }

    private void on() {
        light.on();
        tv.on();
        airCondition.on();
    }


}
